<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>

<div id="app">
  <div v-if="books.length>0">
  <table>
    <thead>
      <tr>
        <td></td>
        <td>名称</td>
        <td>价格</td>
        <td>数量</td>
        <td>操作</td>
      </tr>
    </thead>
    <tbody>
      <tr v-for="(item,index) in books">
        <td>{{item.id}}</td>
        <td>{{item.name}}</td>
        <td>{{item.price | showPrice}}</td>
        <td>
          <button @click="decCount(index)" :disabled="item.count<=1">-</button>
          {{item.count}}
          <button @click="incCount(index)">+</button>
        </td>
        <td>
          <button @click="removeHandler(index)">移除</button>
        </td>
      </tr>
    </tbody>
  </table>
  <h2>总价格:{{totalPrice | showPrice}}</h2>
  </div>
  <h2 v-else>购物车为空</h2>
</div>
<script src="../js/vue.js"></script>
<script src="main.js"></script>
</body>
</html>